package com.fr.data.core.db.handler;

import com.fr.data.core.db.dialect.Dialect;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ByteTypeHandler extends AbstractSQLTypeHandler
{
  public void setValue(PreparedStatement paramPreparedStatement, int paramInt1, Object paramObject, int paramInt2, Dialect paramDialect)
    throws SQLException
  {
    if (paramObject instanceof Byte)
      paramPreparedStatement.setByte(paramInt1, ((Byte)paramObject).byteValue());
    else
      checkIsString(paramPreparedStatement, paramInt1, paramObject, paramInt2);
  }

  protected void parseString(PreparedStatement paramPreparedStatement, int paramInt, String paramString)
    throws Exception
  {
    int i = Integer.valueOf(paramString).intValue();
    if ((i > 255) || (i < -127))
      return;
    paramPreparedStatement.setString(paramInt, paramString);
  }

  public Object getValue(ResultSet paramResultSet, int paramInt1, int paramInt2, Dialect paramDialect)
    throws SQLException
  {
    return getIntegerValue(paramResultSet, paramInt1);
  }
}